<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function Parent(n){
    this.name = n
  }
  Parent.prototype.show = function(){
    console.log(this.name)
  }

  function Child(n){
    Parent.call(this, n);
  }
  // 原型对象
  Child.prototype = {
    ...Parent.prototype,
    constructor: Child
  }
  // 原型链
  // Child.prototype = new Parent();
  // Child.prototype.constructor = Child;

  Child.prototype.show = function(){
    console.log("hahaha")
  }

  const p = new Parent("hello")
  console.log(p)
  p.show();

  const c = new Child("world");
  console.log(c)
  c.show();
  
</script>
</html>